<template>
  <div class="onboarding">
    <el-card>
      <template #header>
        <div class="card-header">
          <span>入职办理</span>
          <el-button type="primary" @click="handleAdd">办理入职</el-button>
        </div>
      </template>
      <el-table :data="onboardingList" border style="width: 100%">
        <el-table-column prop="id" label="ID" width="100" />
        <el-table-column prop="name" label="姓名" width="120" />
        <el-table-column prop="username" label="用户名" width="120" />
        <el-table-column prop="department" label="部门" width="120" />
        <el-table-column prop="position" label="职位" width="120" />
        <el-table-column prop="entryDate" label="入职日期" width="120" />
        <el-table-column prop="status" label="状态" width="120">
          <template #default="{ row }">
            <el-tag :type="row.status === '已完成' ? 'success' : 'warning'">
              {{ row.status }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200">
          <template #default="{ row }">
            <el-button type="primary" size="small" @click="handleEdit(row)">编辑</el-button>
            <el-button v-if="row.status === '待办理'" type="success" size="small" @click="handleComplete(row)">
              完成
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { ElMessage } from "element-plus";

const onboardingList = ref([
  {
    id: 1,
    name: "王五",
    username: "wangwu",
    department: "技术部",
    position: "测试工程师",
    entryDate: "2025-01-20",
    status: "待办理",
  },
  {
    id: 2,
    name: "赵六",
    username: "zhaoliu",
    department: "产品部",
    position: "产品经理",
    entryDate: "2025-01-18",
    status: "已完成",
  },
]);

const handleAdd = () => {
  ElMessage.info("办理入职功能待实现");
};

const handleEdit = (row) => {
  ElMessage.info(`编辑入职信息：${row.name}`);
};

const handleComplete = (row) => {
  row.status = "已完成";
  ElMessage.success(`已完成 ${row.name} 的入职办理`);
};
</script>

<style scoped>
.onboarding {
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
